package JackSu.多线程;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class _09线程池的方式 {
    /**
     * 1.减少消耗
     * 2.提高响应
     * 3.便于管理
     * @param args
     */


    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        executorService.execute(new number1());//Runable方式新建线程
//        executorService.submit() Callble方式新建
        //关闭当前线程池
        executorService.shutdown();


    }
}

class number1 implements Runnable {
    @Override
    public void run() {

        for (int i = 0; i < 100; i++) {
            if (i % 2 == 0) {
                System.out.println(Thread.currentThread().getName() + ":" + i);
            }
        }

    }
}
